<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>数据科学大作业——司法小程序</title>
    <!-- CSS -->
    <link href="static/css/bootstrap.css" rel="stylesheet">
    <link href="static/css/blog.css" rel="stylesheet">
  </head>
  <script type="text/javascript">
    String.prototype.replaceAll = function (s1, s2) {
        return this.replace(new RegExp(s1, "gm"), s2);
    };

    window.onload = function(){
    //检查名词，动词，形容词
        var strNouns='{{Nouns}}';
        var strAdjs='{{Adjs}}';
        var strVerbs='{{Verbs}}';
        var strPushpeople='{{pushpeople}}';
        var strPushraces='{{pushraces}}';
        var strPushbirthplace='{{pushbirthplace}}';
        var strPushcourts='{{pushcourts}}';
        var strPushcrimes='{{pushcrimes}}';
        var strPushresults='{{pushresults}}';
        var strPushstates='{{pushstates}}';
        var str2Nouns=strNouns.replaceAll("&#39;","");str2Nouns=str2Nouns.replace('[',"");str2Nouns=str2Nouns.replace(']',"");
        var str2Adjs=strAdjs.replaceAll("&#39;","");str2Adjs=str2Adjs.replace('[',"");str2Adjs=str2Adjs.replace(']',"");
        var str2Verbs=strVerbs.replaceAll("&#39;","");str2Verbs=str2Verbs.replace('[',"");str2Verbs=str2Verbs.replace(']',"");
        var str2Pushpeople=strPushpeople.replaceAll("&#39;","");str2Pushpeople=str2Pushpeople.replace('[',"");str2Pushpeople=str2Pushpeople.replace(']',"");
        var str2Pushraces=strPushraces.replaceAll("&#39;","");str2Pushraces=str2Pushraces.replace('[',"");str2Pushraces=str2Pushraces.replace(']',"");
        var str2Pushbirthplace=strPushbirthplace.replaceAll("&#39;","");str2Pushbirthplace=str2Pushbirthplace.replace('[',"");str2Pushbirthplace=str2Pushbirthplace.replace(']',"");
        var str2Pushcourts=strPushcourts.replaceAll("&#39;","");str2Pushcourts=str2Pushcourts.replace('[',"");str2Pushcourts=str2Pushcourts.replace(']',"");
        var str2Pushcrimes=strPushcrimes.replaceAll("&#39;","");str2Pushcrimes=str2Pushcrimes.replace('[',"");str2Pushcrimes=str2Pushcrimes.replace(']',"");
        var str2Pushresults=strPushresults.replaceAll("&#39;","");str2Pushresults=str2Pushresults.replace('[',"");str2Pushresults=str2Pushresults.replace(']',"");
        var str2Pushstates=strPushstates.replaceAll("&#39;","");str2Pushstates=str2Pushstates.replace('[',"");str2Pushstates=str2Pushstates.replace(']',"");
        var lstNouns=[]
        var lstAdjs=[]
        var lstVerbs=[]
        var lstPushpeople=[]
        var lstPushraces=[]
        var lstPushbirthplace=[]
        var lstPushcourts=[]
        var lstPushcrimes=[]
        var lstPushresults=[]
        var lstPushstates=[]
        if(str2Nouns.length>0){
          lstNouns=str2Nouns.split(",");
        }
        if(str2Adjs.length>0){
          lstAdjs=str2Adjs.split(",");
        }
        if(str2Verbs.length>0){
          lstVerbs=str2Verbs.split(",");
        }
        if(str2Pushpeople.length>0){
          lstPushpeople=str2Pushpeople.split(",");
        }
        if(str2Pushraces.length>0){
          lstPushraces=str2Pushraces.split(",");
        }
        if(str2Pushbirthplace.length>0){
          lstPushbirthplace=str2Pushbirthplace.split(",");
        }
        if(str2Pushcourts.length>0){
          lstPushcourts=str2Pushcourts.split(",");
        }
        if(str2Pushcrimes.length>0){
          lstPushcrimes=str2Pushcrimes.split(",");
        }
        if(str2Pushresults.length>0){
          lstPushresults=str2Pushresults.split(",");
        }
        if(str2Pushstates.length>0){
          lstPushstates=str2Pushstates.split(",");
        }
        setBoxesValues(lstNouns,lstVerbs,lstAdjs,lstPushpeople,lstPushraces,lstPushbirthplace,lstPushcourts,
        lstPushcrimes,lstPushresults,lstPushresults,lstPushstates);
        fixpeople();
        fixdestinations();
        fixcrimes();
        fixcourts();
        fixresults();
        fixstates();
        fixraces();
    }
    //修改复选框的value值
    function setBoxesValues(lstNouns,lstVerbs,lstAdjs,lstPushpeople,lstPushraces,lstPushbirthplace,lstPushcourts,
        lstPushcrimes,lstPushresults,lstPushresults,lstPushstates){
      var lstAll = lstNouns.concat(lstVerbs,lstAdjs)
      var lenOfBoxes = lstAll.length

      if(lenOfBoxes>0){
      var peopleboxes = document.getElementsByName("peopleboxes");
      var racesboxes = document.getElementsByName("racesboxes");
      var destinationsboxes = document.getElementsByName("destinationsboxes");
      var crimesboxes = document.getElementsByName("crimesboxes");
      var courtsboxes = document.getElementsByName("courtsboxes");
      var resultsboxes = document.getElementsByName("resultsboxes");
      var statesboxes = document.getElementsByName("statesboxes");
        var peoplei=0;
        var racesi=0;
        var birthplacei=0;
        var courtsi=0;
        var crimesi=0;
        var resultsi=0;
        var statesi=0;

        for(peoplei=0;peoplei<lstPushpeople.length;peoplei++){
             peopleboxes[peoplei].value=lstPushpeople[peoplei];

        }

        for(racesi=0;racesi<lstPushraces.length;racesi++){
             racesboxes[racesi].value=lstPushraces[racesi];
        }
        for(birthplacei=0;birthplacei<lstPushbirthplace.length;birthplacei++){
             destinationsboxes[birthplacei].value=lstPushbirthplace[birthplacei];
        }
        for(crimesi=0;crimesi<lstPushcrimes.length;crimesi++){
             crimesboxes[crimesi].value=lstPushcrimes[crimesi];
        }
        for(courtsi=0;courtsi<lstPushcourts.length;courtsi++){
             courtsboxes[courtsi].value=lstPushcourts[courtsi];
        }
        for(resultsi=0;resultsi<lstPushresults.length;resultsi++){
             resultsboxes[resultsi].value=lstPushresults[resultsi];
        }
        for(statesi=0;statesi<lstPushstates.length;statesi++){
             statesboxes[statesi].value=lstPushstates[statesi];
        }
        for(var i=0;i<lenOfBoxes;i++){
          if(!lstPushpeople.indexOf(lstAll[i])){peopleboxes[peoplei].value=lstAll[i];peoplei++;}
          if(!lstPushraces.indexOf(lstAll[i])){racesboxes[racesi].value=lstAll[i];racesi++;}
          if(!lstPushbirthplace.indexOf(lstAll[i])){destinationsboxes[birthplacei].value=lstAll[i];birthplacesi++}
          if(!lstPushcrimes.indexOf(lstAll[i])){crimesboxes[crimesi].value=lstAll[i];crimesi++;}
          if(!lstPushcourts.indexOf(lstAll[i])){courtsboxes[courtsi].value=lstAll[i];courtsi++}
          if(!lstPushresults.indexOf(lstAll[i])){resultsboxes[resultsi].value=lstAll[i];resultsi++;}
          if(!lstPushstates.indexOf(lstAll[i])){statesboxes[statesi].value=lstAll[i];statesi++;}
        }
      }
    }
    function changeInputBlank(boxesName,blankId){
      var boxes = document.getElementsByName(boxesName);
          var values = new Array();
          for(var i = 0; i < boxes.length; i++){
              if(boxes[i].checked){
                  values.push(boxes[i].value);
              }
          }
          var blank = document.getElementById(blankId);

          blank.value=""
          for(var i=0;i<values.length;i++){
              blank.value=blank.value.concat(values[i]+";");
          }

    }

    function fixpeople(){
        changeInputBlank('peopleboxes','people');
	}
	function fixdestinations(){
	    changeInputBlank('destinationsboxes','destinations');
	}
	function fixcrimes(){
	    changeInputBlank('crimesboxes','crimes');
	}
	function fixcourts(){
	    changeInputBlank('courtsboxes','courts');
	}
	function fixresults(){
	    changeInputBlank('resultsboxes','results');
	}
	function fixstates(){
	    changeInputBlank('statesboxes','states');
	}
	function fixraces(){
	    changeInputBlank('racesboxes','races');
	}

    </script>

  <body>
    <div class="blog-masthead">
      <div class="container">
        <nav class="blog-nav">
          <a class="blog-nav-item active" href="/" methods="post">首页</a>
          <a class="blog-nav-item" href="#part1">案件输入框</a>
          <a class="blog-nav-item" href="#part2">司法与技术</a>
          <a class="blog-nav-item" href="#part3">小组介绍</a>
        </nav>
      </div>
    </div>
	<div class="intr">
    	<span class="avtar"></span>
        <p class="peointr">司法大数据自动化标注与分析</p>
        <p class="peointr">请在主要功能区文本框内输入案例</p>
    </div>
    <div class="title" id="part1">案件输入框</div>



    <div class="content">
      <a href="/spider">
        <button>爬取案例</button>
      </a>
      <p>爬取案例数量：{{spiderNum}}(再次爬取将清空数量再从当前日期向前爬取）</p>
      <a href="/download/spiderCases">
        <button>下载爬取的案例到本地</button>
      </a>
      <br>
      <a  href = "/upload" >
     <button>上传文件</button >
      </a>
      <textarea placeholder="请输入内容" name="inputArea" style="width:1000px;height:300px;" form="submitForm">{{content}}</textarea>
        <form id="submitForm" action=""  method="post">
          <button type="submit">进行初步标注</button>
        </form>
      <a  href = "/download/TXT" >
        <button>保存文书为TXT文件到本地</button>
      </a>
    </div>

    <div class="title" id="part1.1">标注展示框</div>

    <div class="content" id="display">
      {% for key in content2%}
      <p class="values">{{key}}:{{content2.get(key)}}</p>
      <br>
      {% endfor %}
      <a  href = "/download/JSON" >
     <button>保存标注为JSON文件到本地</button>
      </a>
    </div>



    <div class="title" id="part2">司法与技术</div>
    <div class="content">
        <ul class="nav nav-tabs" role="tablist">
          <li class="active"><a href="#party" role="tab" data-toggle="tab">当事人</a></li>
          <li><a href="#race" role="tab" data-toggle="tab">民族</a></li>
          <li><a href="#birthplace" role="tab" data-toggle="tab">出生地</a></li>
          <li><a href="#crime" role="tab" data-toggle="tab">案由</a></li>
          <li><a href="#court" role="tab" data-toggle="tab">相关法院</a></li>
          <li><a href="#result" role="tab" data-toggle="tab">判处结果</a></li>
          <li><a href="#state" role="tab" data-toggle="tab">审判性质</a></li>
        </ul>
        <div class="tab-content">
          <div class="tab-pane active" id="party">
            当事人：<input type="text" form="submitForm" name="people" id="people" style="width:800px;"
                       placeholder="请输入所有当事人" value="">
          	<p class="text">推荐</p>
            {% for person in pushpeople %}
            <input type="checkbox" value="" name="peopleboxes" checked>{{person}}
            {% endfor %}
          	<p class="text">名词</p>
            {% for noun in Nouns %}
              {% if noun not in pushpeople %}
              <input type="checkbox" value="dsrn" name="peopleboxes">{{noun}}
              {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="dsrv" name="peopleboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="peopleboxes">{{adj}}
            {% endfor %}
            <button id="btn1" onclick="fixpeople()">修改标注为选中内容</button>
          </div>

          <div class="tab-pane" id="race">
            民族：<input type="text" form="submitForm" name="races" id="races" style="width:800px;"
                      placeholder="请输入民族" value="">
          	<p class="text">推荐</p>
            {% for race in pushraces %}
            <input type="checkbox" value="" name="racesboxes" checked>{{race}}
            {% endfor %}
          	<p class="text">名词</p>

            {% for noun in Nouns %}
              {% if noun not in pushraces %}
              <input type="checkbox" value="" name="racesboxes">{{noun}}
              {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="racesboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="racesboxes">{{adj}}
            {% endfor %}
            <button id="btn2" onclick="fixraces()">修改标注为选中内容</button>
          </div>

          <div class="tab-pane" id="birthplace">
            出生地：<input type="text" form="submitForm" name="destinations" id="destinations" style="width:800px;"
                       placeholder="请输入出生地" value="">
          	<p class="text">推荐</p>
            {% for birthplace in pushbirthplace %}
            <input type="checkbox" value="" name="destinationsboxes" checked>{{birthplace}}
            {% endfor %}
          	<p class="text">名词</p>
            {% for noun in Nouns %}
              {% if noun not in pushbirthplace %}
              <input type="checkbox" value="" name="destinationsboxes">{{noun}}
              {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="destinationsboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="destinationsboxes">{{adj}}
            {% endfor %}
            <button id="btn3" onclick="fixdestinations()">修改标注为选中内容</button>
          </div>

          <div class="tab-pane" id="crime">
            案由：<input type="text" form="submitForm" name="crimes" id="crimes" style="width:800px;"
                      placeholder="请输入案由" value="">
            <p class="text">推荐</p>
            {% for crime in pushcrimes %}
            <input type="checkbox" value="" name="crimesboxes" checked>{{crime}}
            {% endfor %}
          	<p class="text">名词</p>
            {% for noun in Nouns %}
              {% if noun not in pushcrimes %}
              <input type="checkbox" value="" name="crimesboxes">{{noun}}
              {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="crimesboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="crimesboxes">{{adj}}
            {% endfor %}
            <button id="btn4" onclick="fixcrimes()">修改标注为选中内容</button>
          </div>

          <div class="tab-pane" id="court">
            相关法院：<input type="text" form="submitForm" name="courts" id="courts" style="width:800px;"
                        placeholder="请输入相关法院" value="">
          	<p class="text">推荐</p>
            {% for court in pushcourts %}
            <input type="checkbox" value="" name="courtsboxes" checked>{{court}}
            {% endfor %}
            <p class="text">名词</p>
            {% for noun in Nouns %}
            {% if noun not in pushcourts %}
            <input type="checkbox" value="" name="courtsboxes">{{noun}}
            {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="courtsboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="courtsboxes">{{adj}}
            {% endfor %}
            <button id="btn5" onclick="fixcourts()">修改标注为选中内容</button>
          </div>

          <div class="tab-pane" id="result">
            判处结果：<input type="text" form="submitForm" name="results" id="results" style="width:800px;"
                        placeholder="请输入判决结果" value="">
          	<p class="text">推荐</p>
            {% for result in pushresults %}
            <input type="checkbox" value="" name="resultsboxes" checked>{{result}}
            {% endfor %}
          	<p class="text">名词</p>
            {% for noun in Nouns %}
            {% if noun not in pushresult %}
            <input type="checkbox" value="" name="resultsboxes">{{noun}}
            {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="resultsboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="resultsboxes">{{adj}}
            {% endfor %}
            <button id="btn6" onclick="fixresults()">填充标注为选中内容</button>
          </div>

          <div class="tab-pane" id="state">
            审判性质：<input type="text" form="submitForm" name="states" id="states" style="width:800px;"
                        placeholder="请输入审判性质" value="">
          	<p class="text">推荐</p>
            {% for state in pushstates %}
            <input type="checkbox" value="" name="statesboxes" checked>{{state}}
            {% endfor %}
          	<p class="text">名词</p>
            {% for noun in Nouns %}
            {% if noun not in pushstates %}
            <input type="checkbox" value="" name="statesboxes">{{noun}}
            {% endif %}
            {% endfor %}
            <p class="text">动词</p>
            {% for verb in Verbs %}
            <input type="checkbox" value="" name="statesboxes">{{verb}}
            {% endfor %}
            <p class="text">形容词</p>
            {% for adj in Adjs %}
            <input type="checkbox" value="" name="statesboxes">{{adj}}
            {% endfor %}
            <button id="btn7" onclick="fixstates()">修改标注为选中内容</button>
          </div>
        </div>
      <button type="submit" form="submitForm">保存修改</button>
      请确认修改全部完成，修改以输入框中的文字为准，保存后所有输入框内的文字将重置
    </div>
    <div class="blog-footer">

    </div>
    <a href="" class="btt">顶部</a>
    <!-- Js-->

    <script src="static/js/jquery-1.9.1.min.js"></script>
    <script src="static/js/bootstrap.min.js"></script>
    <script src="static/js/plugin.js"></script>
    </div>
</body>
</html>














